Lab report

Exercises

Exercise 1

wine%>%
str('data.frame')
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 1599 obs. of  13 variables:
##  $ Fixed_acidity       : num  7.4 7.8 7.8 11.2 7.4 7.4 7.9 7.3 7.8 7.5 ...
##  $ Volatile_acidity    : num  0.7 0.88 0.76 0.28 0.7 0.66 0.6 0.65 0.58 0.5 ...
##  $ Citric_acid         : num  0 0 0.04 0.56 0 0 0.06 0 0.02 0.36 ...
##  $ Residual_sugar      : num  1.9 2.6 2.3 1.9 1.9 1.8 1.6 1.2 2 6.1 ...
##  $ Chlorides           : num  0.076 0.098 0.092 0.075 0.076 0.075 0.069 0.065 0.073 0.071 ...
##  $ Free_sulfur_dioxide : num  11 25 15 17 11 13 15 15 9 17 ...
##  $ Total_sulfur_dioxide: num  34 67 54 60 34 40 59 21 18 102 ...
##  $ Density             : num  0.998 0.997 0.997 0.998 0.998 ...
##  $ pH                  : num  3.51 3.2 3.26 3.16 3.51 3.51 3.3 3.39 3.36 3.35 ...
##  $ Sulphates           : num  0.56 0.68 0.65 0.58 0.56 0.56 0.46 0.47 0.57 0.8 ...
##  $ Alcohol             : num  9.4 9.8 9.8 9.8 9.4 9.4 9.4 10 9.5 10.5 ...
##  $ Quality             : num  5 5 5 6 5 5 5 7 7 5 ...
##  $ Label               : chr  "Average" "Average" "Average" "Average" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   Fixed_acidity = col_double(),
##   ..   Volatile_acidity = col_double(),
##   ..   Citric_acid = col_double(),
##   ..   Residual_sugar = col_double(),
##   ..   Chlorides = col_double(),
##   ..   Free_sulfur_dioxide = col_double(),
##   ..   Total_sulfur_dioxide = col_double(),
##   ..   Density = col_double(),
##   ..   pH = col_double(),
##   ..   Sulphates = col_double(),
##   ..   Alcohol = col_double(),
##   ..   Quality = col_double(),
##   ..   Label = col_character()
##   .. )

13 columns 1599 Rows. Data type of Label = character

Exercise 2

ggplot(data = wine) +
  geom_bar(aes(x = Label),fill="steelblue") +
  # Adding plot title and y-axis label
  labs(title = "Distribution of Red Wines", y = "Count") +
  # Adding a theme to the plot
  theme_minimal() 

Based on the distibution based on the quality of wine, “Average” wine has the largest number produced.

Exercise 3

ggplot(data = wine) +
  geom_bar(aes(x = Label),fill="orange") +
  # Adding plot title and y-axis label
  labs(title = "Distribution of Red Wines", y = "Count") +
  # Adding a theme to the plot
  theme_bw() 

Exericse 4

# From "GGally" package
ggcorr(wine[1:12],
       label = TRUE, 
       label_size = 2, 
       label_alpha = TRUE,
       size = 3)

Alcohol has the highest positve correlation with quality, and volatile acidity has the highest negative correlation with quality.

Exericse 5

It can be concluded that alcohol correlates strongest with producing the greatest quality of wine in most cases as displayed in the chart. On the other hand, volatile acidity negtively impacts the quality of wine most often, hindering the results of quality on a consistent basis.

Exericse 6

wine %>%
ggplot() +
  geom_point(mapping = aes(x = Alcohol, y = Volatile_acidity, color = Alcohol)) +
  labs(x = "Alcohol %", title="Alcohol VS Volatile Acidity") +
  theme_get()

Exericse 7

ggplotly(ggplot(data = wine) +
  geom_point(mapping = aes(x = Alcohol, y = Volatile_acidity, color = Alcohol)) +
  labs(x = "Alcohol %", title="Alcohol VS Volatile Acidity") +
  theme_get())

Exericse 8

map %>%
  leaflet() %>%
  addTiles() %>%
  addMarkers(
    lat = ~Lat,
    lng = ~Lon
  )

Exercise 9

map %>%
  leaflet() %>%
  addTiles() %>%
  addCircleMarkers(
    lat = ~Lat,
    lng = ~Lon
  )

Exericse 10

map %>%
leaflet() %>%
  addProviderTiles(providers$OpenStreetMap.DE) %>%
  setView(lng = -175.243683, lat =  50.052235, zoom = 3) %>%
  addCircleMarkers(lat = ~Lat, lng = ~Lon)

After changing the provider of the map it changed the style it was shown. Adjusting the values for longitude and latitude changes the default location shown for winery’s within a particular region.

Exericse 11

map %>%
leaflet() %>%
  addProviderTiles(providers$Esri.WorldStreetMap) %>%
  setView(lng = -100.243683, lat =  34.052235, zoom = 3) %>%
  addCircleMarkers(lat = ~Lat, lng = ~Lon,
             popup = paste("Name:", map$Name, "<br>",
                            "Rank:", map$Rank, "<br>",
                           "Address:", map$Address, "<br>"))